package com.sophossystems.client.asmon.action;

import org.apache.log4j.Logger;


import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;

/**
 * Acts as a controller to handle actions
 * related to registering a user.
 * @author Juan Velez Ballesteros
 *
 */

public class HelloAction extends ActionSupport {
	
	  
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Logger log = Logger.getLogger(LoginAction.class);
	

	private String username = null;
	  
	private String password = null;

	  
	@RequiredStringValidator(message="Supply name")
	  
	public String getUsername() {
		log.debug("Hello Action");
	 return username;
	  }

	 
	  
	public void setUsername(String value) {

	    username = value;
	  }
	  
	  
	@RequiredStringValidator(message="Supply password")

	  
	public String getPassword() {
	  
	return password;
	  }

	  
	  
	public void setPassword(String value) {
	  
	password = value;
	  }

	  
	  
	 
	@Override
	public String execute() throws Exception {
	  
	System.out.println("Validating login");
	if(!getUsername().equals("Admin") || !getPassword().equals("Admin")){
	  addActionError("Invalid user name or password! Please try again!");
	 
	 return ERROR;
	  
	}
	else{
	 
	 return SUCCESS;
	  }
	  
	  }
	


}
